package com.example.book.service.impl;

import com.example.book.domain.Book;
import com.example.book.mapper.BookMapper;
import com.example.book.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;
    @Override
    public List<Book> getBooksByUserId(Long userId) {
        return bookMapper.selectBooksByUserId(userId);
    }

    @Override
    public int addBook(Book book) {
        return bookMapper.insert(book);
    }

    @Override
    public int removeBookByBookId(Long bookId) {
        return bookMapper.deleteByPrimaryKey(bookId);
    }

    @Override
    public int updateBookByBookId(Book book) {
        return bookMapper.updateByPrimaryKey(book);
    }

    @Override
    public Book getBookByBookId(Long id) {
        return bookMapper.selectBookByBookId(id);
    }

    @Override
    public List<Book> getBookByBookName(String name,Integer userId) {
        return bookMapper.selectBookByBookName(name,userId);
    }
}
